var fasArray = new Array("208","209","210","211","212","214","215","230","231","232");
var list = new Array();

fas_datadeal_success=function (result) {
    var data = result.data;
    if(data.length>0){
        var index = 0;
        for(var i=0;i<data.length;i++){
            if(i==0 || i%3==0){
                var object = new Object();
                object.ID = fasArray[index];
                object.B01 = data[i];
                object.D01 = data[i+1];
                object.G01 = data[i+2];
                list.push(object);
                index++;
            }
        }
    }
    if(list.length>0){
        for(var i=0;i<list.length;i++){
            var id = list[i].ID;
            var b01 = list[i].B01;
            var d01 = list[i].D01;
            var g01 = list[i].G01;
            if(b01=="0" && d01 == "0"){
                $("#"+id).attr("src",basePath+"static/images/fas/GYQ_green.png");
            }
            if(b01=="0" && d01 == "1"){
                $("#"+id).attr("src",basePath+"static/images/fas/GYQ_yellow.png");
            }
            if(b01 == "1"){
                $("#"+id).attr("src",basePath+"static/images/fas/GYQ_red.png");
            }
            if(g01 == "1"){
                $("#"+id).attr("src",basePath+"static/images/fas/GYQ_grey.png");
            }
//						else{
//							//蓝色
//							$("#"+id).attr("src",basePath+"static/images/fas/GYQ_blue.png");
//						}
            //显示
            if($("#zhsktq").css('display')=='block'){
                if(null != devcode && '' != devcode){
                    if(devcode==id){
                        $("#devcode1").html(id);
                        $("#devcode2").html(id);
                        if(b01=="0"){
                            $("#firealarm").html('无');
                        }else{
                            $("#firealarm").html('报警');
                        }
                        if(g01=='0'){
                            $("#quarantine").html('无');
                        }else{
                            $("#quarantine").html('报警');
                        }
                        if(d01=="0"){
                            $("#signal").html('无');
                        }else{
                            $("#signal").html('报警');
                        }

                    }
                }
            }
        }
    }
}
fas_datadeal_error=function () {
    //code返回非200
    if(fasArray.length > 0){
        for(var i=0;i<fasArray.length;i++){
            $("#"+fasArray[i]).attr("src",basePath+"static/images/fas/GYQ_blue.png");
        }
    }
}


setInterval(function() {
	getFasStatus()
}, 3000);

//获取烟感状态数据
function getFasStatus(){
    if(comm_rundemo){
        var _tmpdata={
            "code": "200",
            "type": null,
            "message": null,
            "data": [
                "1",
                "1",
                "1",
                "0",
                "0",
                "0",
                "0",
                "0",
                "0",
                "0",
                "0",
                "0",
                "0",
                "0",
                "0",
                "0",
                "0",
                "0",
                "0",
                "0",
                "1",
                "0",
                "0",
                "0",
                "0",
                "0",
                "0",
                "0",
                "0",
                "0"
            ]
        };
        fas_datadeal_success(_tmpdata);
    }
    else {
        $.ajax({
         type:'post',
         url: targetPath + '/rest/getData?start=v0&end=v29',
         dataType: 'json',//here
         success: function(result)
         {
         if(result.code=="200"){
         fas_datadeal_success(result);
         }
         else{
         fas_datadeal_error();
         }

         },
         error : function(result){
         fas_datadeal_error();
         }
         });
    }

}

var devcode="";
function show1(obj){
//		if($("#zhsktq").css('display')=='block'){
//			
//		}
		$("#zhsktq").show();
		devcode = obj;
	
	
}

function hide1(){
	$("#zhsktq").hide();
}
